"""
写站内信页面类
"""
from ..base_page import BasePage
from selenium.webdriver.common.by import By


class AddSystemMessagePage(BasePage):
    #数据
    url="/crm/index.php?m=message"
    #定位器
    gd_locator = (By.LINK_TEXT, "更多")
    znx_locator = (By.LINK_TEXT, "站内信")
    xx_locator = (By.CSS_SELECTOR, "#send")
    bgs_locator = (By.CSS_SELECTOR,"#dialog-message-send > form > table > tbody > tr:nth-child(1) > td:nth-child(2) > ul > li.active > a")
    xzsy_locator = (By.CLASS_NAME, "check_all")
    nr_locator = (By.CLASS_NAME, "span5")
    save_locator = (By.CLASS_NAME, "btn btn-primary")
    short_message_locator = (By.CSS_SELECTOR, "body > div.container > div.page-header > h4")
    tips_success_locator = (By.CLASS_NAME, "body > div.container > div.alert.alert-success")

    def write_message(self): #写信
        self.click(self.xx_locator)
    def select_department(self):  #选择收件的部门
        self.click(self.bgs_locator)
    def select_person(self):   #选择收件人
        self.click(self.xzsy_locator)
    def write_content(self,content):    #写内容
        self.send_keys(self.nr_locator,content)
    def short_message(self):    #用“短信息”断言
        return self.find_element(self.short_message_locator).text
    def short_message(self):    #短信发送成功断言
        return self.find_element(self.short_message_locator).text